home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 051-075 / 058 / bigview / bigview.c < prev    next >
C/C++ Source or Header  |  1995-03-13  |  3KB  |  104 lines

  1. /* BigView.C - (c) 1987 DJH
  2.  
  3.     BigView will display any IFF picture independent of the physical
  4.   display size. Default display size is 320 x 200 lo-res; HIRES or LACE
  5.   attributes added if user width/height exceeds low resolution boundaries.
  6.  
  7.     Note that we do not actually call ScrollVPort, since we want to
  8.   maintain Intuition compatability; the principle is the same, however.
  9.   Note that not all screen widths/resolutions scroll equally smoothly;
  10.   experiment! Also : the Rx/RyOffsets seem able to exceed the 1K RKM
  11.   limitations; investigate.
  12. */
  13.  
  14. #include "iff.h" /* ReadILBM.C defines */
  15.  
  16. void *IntuitionBase,*GfxBase;
  17.  
  18. main(argc,argv)
  19. int argc;
  20. char *argv[];
  21. {
  22.   struct PicMap picmap;
  23.   struct NewScreen newscreen;
  24.   struct Screen *screen;
  25.   int status,dwidth,dheight,i;
  26.  
  27.   switch(argc) {
  28.     case 0:  exit(0); break; /* arrgh! WorkBench! */
  29.     case 2:  dwidth=320; dheight=200; break;
  30.     case 4:  sscanf(argv[2],"%d",&dwidth);
  31.              sscanf(argv[3],"%d",&dheight);
  32.              break;
  33.     default: puts("BigView file [width,height]"); exit(0);
  34.   }
  35.  
  36.   IntuitionBase=OpenLibrary("intuition.library",0);
  37.   GfxBase=OpenLibrary("graphics.library",0);
  38.  
  39.   if (ReadILBM(argv[1],0,&picmap)) exit(0);
  40.  
  41.   setmem(&newscreen,sizeof(newscreen),0);
  42.  
  43.   /* user dimensions can be smaller, but not larger than picture! */
  44.  
  45.   if (dwidth>picmap.BitMap.BytesPerRow*8) dwidth=picmap.BitMap.BytesPerRow*8;
  46.   if (dheight>picmap.BitMap.Rows) dheight=picmap.BitMap.Rows;
  47.   
  48.   newscreen.Width=dwidth; newscreen.Height=dheight;  
  49.  
  50.   newscreen.ViewModes=picmap.ViewModes & HAM; /* WE decide other bits */
  51.  
  52.   if (dwidth>LOWIDTH) newscreen.ViewModes|=HIRES;
  53.   if (dheight>LOHEIGHT) newscreen.ViewModes|=LACE;
  54.  
  55.   newscreen.Type=CUSTOMSCREEN|CUSTOMBITMAP;
  56.   newscreen.Depth=picmap.BitMap.Depth;
  57.   newscreen.CustomBitMap=&picmap.BitMap;
  58.   newscreen.DetailPen=0; newscreen.BlockPen=1;
  59.  
  60.   screen=OpenScreen(&newscreen);
  61.   LoadRGB4(&screen->ViewPort,&picmap.colormap[0],1<<newscreen.Depth);
  62.  
  63.   Scroll_Around(screen,dwidth,dheight); Delay(200);
  64.  
  65.   CloseScreen(screen); FreeBitMap(&picmap.BitMap);
  66. }
  67.  
  68. Scroll_Around(screen,dwidth,dheight)
  69. struct Screen *screen;
  70. int dwidth,dheight;
  71. {
  72.   short i,
  73.         xdelta=screen->BitMap.BytesPerRow*8-dwidth,
  74.         ydelta=screen->BitMap.Rows-dheight;
  75.  
  76.   if (xdelta) /* any room to scroll right? */ 
  77.     for (i=1;i<=xdelta;i++) {
  78.       screen->ViewPort.RasInfo->RxOffset=i;
  79.       MakeScreen(screen);
  80.       RethinkDisplay();
  81.     }
  82.  
  83.   if (ydelta) /* any room to scroll down? */
  84.     for (i=1;i<=ydelta;i++) {
  85.       screen->ViewPort.RasInfo->RyOffset=i;
  86.       MakeScreen(screen);
  87.       RethinkDisplay();
  88.     }
  89.  
  90.   if (xdelta)
  91.     for (i=xdelta;i;i--) {
  92.       screen->ViewPort.RasInfo->RxOffset=i-1;
  93.       MakeScreen(screen);
  94.       RethinkDisplay();
  95.     }
  96.  
  97.   if (ydelta)
  98.     for (i=ydelta;i;i--) {
  99.       screen->ViewPort.RasInfo->RyOffset=i-1;
  100.       MakeScreen(screen);
  101.       RethinkDisplay();
  102.     }
  103. }
  104.